<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>Document</title>
</head>
<body>

<script>
    (function(){
        var b;
        (function(){
            var a = function(){
                console.log(b);
            };
            window.a = a;
        })();
    })();





</script>

<script>
    (function(){
        var b = "123";
        window.a();
     })();
</script>

</body>
</html>